package com.myapp.ruyixing.http;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONObject;

import com.myapp.ruyixing.model.ActivityList;

public class ActivityListParser extends RYJSONParser {
	@Override
	public Object parse(JSONObject jsonObject) {
		ActivityList actList = new ActivityList();

		ListModelParser.parseListModel(actList, jsonObject);
		JSONObject data = jsonObject.optJSONObject("data");
		JSONArray array = data.optJSONArray("items");
		actList.items = new ArrayList<ActivityList.Act>();
		for (int i = 0; array != null && i < array.length(); i++) {
			JSONObject object = array.optJSONObject(i);
			if (object != null) {
				ActivityList.Act act = new ActivityList.Act();
				act.picurl = object.optString("picurl", "");
				act.datetime = object.optString("datetime", "");
				act.aid = object.optString("aid", "");
				act.num = object.optString("num", "");
				act.originalprice = object.optString("originalprice", "");
				act.presentprice = object.optString("presentprice", "");
				act.title = object.optString("title", "");
				actList.items.add(act);
			}
		}

		return actList;

	}
}
